import request from "@/libs/request";

const basePath = '/appcloud-data' ;
const basePathResource = '/appcloud-resource' ;

export const apiUrls = {
	getActiveIp : basePath + '/api/host/getActiveIp',
	getHostInfCluster : basePath + '/api/host/getHostInfCluster',
	getHostInfo : basePath + '/api/host/getHostInfo',
	getHostStatus : basePath + '/api/host/getHostStatus',
	// getIpList : basePath + '/api/host/getIpList',
	saveHost : basePath + '/api/host/saveHost',
  update : basePath + '/api/host/update',
  getDashboardById:'/appcloud-resource/api/resource/host/getDashboardById/',
  getIpList:'/appcloud-resource/api/resource/host/getIpList',
  saveIp:'/appcloud-resource/api/resource/host/saveHost',
  getVncHostUrl:'/appcloud-resource/api/resource/host/getVncHostUrl'
}

export const apiUrlsResource = {
	updateHostCluster : basePathResource + '/api/resource/host/updateHostCluster',
}


// 更新主机集群
export async function updateHostCluster(params){
	return request( apiUrlsResource.updateHostCluster, {
      method:'POST',
      body:params
  })
}


/* ----------------- */


// 保存ip
export async function saveIp(params){
	return request( apiUrls.saveIp, {
      method:'POST',
      body:params
  })
}

//根据集群id获取内存、磁盘监控信息
export async function getDashboardById(id){
	return request( apiUrls.getDashboardById + '?' + 'id' + '=' + id, {
      method:'POST',
  })
}

// 获取主机列表
export async function getIpList(params){
	return request( apiUrls.getIpList , {
      method:'POST',
      body:params
  })
}

// 根据查询可用的ip信息
export async function getActiveIpPost(params){
	return request( apiUrls.getActiveIp , {
      method:'POST',
      body:params
  })
}


// 根据集群id获取IP信息
export async function getHostInfCluster(params){
	return request( apiUrls.getHostInfCluster + `?clusterId=${params.clusterId}`, {
      method:'POST',
      body:params
  })
}


// 根据ip查询主机详情
export async function getHostInfo(params){
	return request( apiUrls.getHostInfo + `?ip=${params.ip}` , {
      method:'POST',
      body:params
  })
}


// 批量查询主机状态
export async function getHostStatus(params){
	return request( apiUrls.getHostStatus , {
      method:'POST',
      body:params
  })
}



// // 分页查询ip信息
// export async function getIpList(params){
// 	return request( apiUrls.getIpList , {
//       method:'POST',
//       body:params
//   })
// }


// 初始化保存主机信息
export async function saveHost(params){
	return request( apiUrls.saveHost , {
      method:'POST',
      body:params
  })
}


// 更新ip信息
export async function update(params){
	return request( apiUrls.update , {
      method:'POST',
      body:params
  })
}

//根据IP 获取远程连接地址
export async function getVncHostUrl(params){
	return request( apiUrls.getVncHostUrl , {
      method:'POST',
      body:params
  })
}